package com.javaEE.gamepigeon.service.impl;

import com.javaEE.gamepigeon.dao.AttentionMapper;
import com.javaEE.gamepigeon.entity.Group;
import com.javaEE.gamepigeon.entity.UserFavorite;
import com.javaEE.gamepigeon.service.AttentionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AttentionServiceImpl implements AttentionService {

    @Autowired
    AttentionMapper attentionDao;


    @Override
    public boolean addFavorite(Integer userId, Integer comId, Integer weight, String note,Integer groupId) {
        if(weight==null||weight==0){
            weight=3;
        }
        if(note==null){
            note="";
        }
        return attentionDao.addFavorite(userId,comId,weight,note,groupId)==1;
    }

    @Override
    public boolean deleteFavorite(Integer userId, Integer comId) {
        return attentionDao.deleteFavorite(userId,comId)==1;
    }

    @Override
    public List<UserFavorite> queryFavorite(Integer userId) {
        return attentionDao.queryFavorite(userId);
    }

    @Override
    public boolean addGroup(Integer userId, String name) {
        return attentionDao.addGroup(userId,name)==1;
    }

    @Override
    public List<Group> queryGroup(Integer userId) {
        return attentionDao.queryGroup(userId);
    }

    @Override
    public boolean deleteGroup(Integer groupId) {
        return attentionDao.deleteGroup(groupId)==1;
    }

    @Override
    public boolean updateGroup(Integer groupId, String groupName) {
        return attentionDao.updateGroup(groupId,groupName)==1;
    }

    @Override
    public List<UserFavorite> getCompetition(Integer groupId) {
        return attentionDao.getCompetition(groupId);
    }
}
